using System;

namespace Kiwi.Container.Lifetime
{
    public class DisposableLifetimePolicy : ILifetimePolicy
    {
        #region ILifetimePolicy Members

        public object StartLife(object component)
        {
            return component;
        }

        public object EndLife(object component)
        {
            var disposable = component as IDisposable;
            if (disposable != null)
            {
                disposable.Dispose();
            }
            return component;
        }

        #endregion
    }
}